// then正常返回resolved，里面报错则返回rejected
// catch正常返回resolved，里面报错则返回rejected


const p1 = Promise.resolve().then(() => {
  return 100
})
// console.log('p1',p1);//resolved  触发后 then 回调
console.log('p1',p1); // resolved

const p2 = Promise.resolve().then(() => {
  throw new Error('then error')
})
console.log('p2',p2);// rejected 触发后 catch回调
p2.then(() => {
  console.log(456);
}).catch(()=> {
  console.log(567);
})

console.log('p2',p2); // rejected

const p3 = Promise.reject('my error').catch((err) => {
  console.log(err);
})
console.log('p3',p3);  // resolved 注意
p3.then(()=> {
  console.log(100);   
})
const p4 = Promise.reject('my error').catch(() => {
  throw new Error('catch err')
})
console.log('p4',p4); // rejected

//试题
Promise.resolve().then(() => {
  console.log(1);  //1 
}).catch(() => {
  console.log(2);
}).then(() => {
  console.log(3);//3
})

Promise.resolve().then(() => {
  console.log(1); //1
  throw new Error('error1')
}).catch(() => {
  console.log(2); //2
}).then(() => {
  console.log(3);//3
})


Promise.resolve().then(() => {
  console.log(1);//1
  throw new Error('error1')
}).catch(() => {
  console.log(2);//2
}).catch(() => {
  console.log(3);//不执行
})